import ElementUI, { MessageBox, Message } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

export default {
    install (Vue, options) {
        Vue.use(ElementUI, {
            size: 'mini'
        })

        // 自定义对话框
        var confirm = function (content) {
            return new Promise((resolve, reject) => {
                MessageBox.confirm(`您确定要${content}数据?`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    resolve()
                }).catch((err) => {
                    Message({
                        type: 'info',
                        message: `已取消${content}`
                    })
                    reject(err)
                })
            })
        }
        Vue.prototype.$YConfirm = confirm
    }
}
